
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>搭建gitlab并使用CICD部署HelloWorld · 小白鼠V技术驿站</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="baidu-site-verification" content="cAxqlT3C5k">
        <meta name="author" content="vonchange">
        
        
    
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-pageview-count/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search-plus/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-code/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-advanced-emoji/emoji-website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="/myfile/gitalk/dist/gitalk.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-donate/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    


    

        
    
    
    
    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="../idea.html" />
    
    
    <link rel="prev" href="frp.html" />
    

    <link href="http://www.vonchange.com/rss" title="小白鼠V技术驿站" rel="alternate" type="application/rss+xml" />

    <style>
    @media only screen and (max-width: 640px) {
        .book-header .hidden-mobile {
            display: none;
        }
    }
    </style>
    <script>
        window["gitbook-plugin-github-buttons"] = {"buttons":[{"user":"vonchange","repo":"vonchange.github.io","type":"star","size":"small"}]};
    </script>

    
        <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
    
    
    
    
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="/apple-touch-icon-precomposed-152.png">
    
    
        
    
    
        
    

    
    <link rel="stylesheet" href="../../gitbook/gitbook-plugin-chart/c3/c3.min.css">
    <script src="../../gitbook/gitbook-plugin-chart/c3/d3.min.js"></script>
    <script src="../../gitbook/gitbook-plugin-chart/c3/c3.min.js"></script>
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    
    
        
        <li>
            <a href="http://www.vonchange.com/" target="_blank" class="custom-link">小白鼠V的技术博客</a>
        </li>
    
    

    
    <li class="divider"></li>
    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    博客总揽
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../mini.html">
            
                <a href="../mini.html">
            
                    
                    spring-data-mybatis-mini极简ORM
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../host.html">
            
                <a href="../host.html">
            
                    
                    闲置主机做开发服务器
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="ubuntu.html">
            
                <a href="ubuntu.html">
            
                    
                    搭建ubuntu server及其k8s
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="frp.html">
            
                <a href="frp.html">
            
                    
                    使用frp代理本地机器到公网
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.3.3" data-path="gitlab-ci.html">
            
                <a href="gitlab-ci.html">
            
                    
                    搭建gitlab并使用CICD部署HelloWorld
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../idea.html">
            
                <a href="../idea.html">
            
                    
                    IDEA全系列最简单的破解方式
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>

    
    <li>
        
        
        
            
        
        
            <a href="http://www.beian.miit.gov.cn/" target="blank" class="gitbook-link">
                鲁ICP备20022988号
            </a>
        
    </li>
    
</ul>

                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >搭建gitlab并使用CICD部署HelloWorld</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div class="search-plus" id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><ul><ul><li><span class="title-icon "></span><a href="#搭建gitlab并使用cicd部署helloworld"><b>1.1.1. </b>搭建gitlab并使用CICD部署HelloWorld</a></li></ul></ul></ul></div><a href="#" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><h3 id="搭建gitlab并使用cicd部署helloworld"><a name="搭建gitlab并使用cicd部署helloworld" class="anchor-navigation-ex-anchor" href="#搭建gitlab并使用cicd部署helloworld"><i class="fa fa-link" aria-hidden="true"></i></a>1.1.1. 搭建gitlab并使用CICD部署HelloWorld</h3>
<h4 id="搭建gitlab"><a name="搭建gitlab" class="anchor-navigation-ex-anchor" href="#搭建gitlab"><i class="fa fa-link" aria-hidden="true"></i></a>搭建gitlab</h4>
<blockquote>
<p>购买一个域名 不备案也可以 最好备案了</p>
<pre><code class="lang-angular2html">docker run --detach \
    --hostname gitlab.frp.?.com \
    --env GITLAB_OMNIBUS_CONFIG=&quot;external_url &apos;http://gitlab.frp.?.com:8099/&apos;; gitlab_rails[&apos;gitlab_shell_ssh_port&apos;] = 6022;gitlab_rails[&apos;gitlab_port&apos;] = 8099;&quot; \
    --publish 443:443 --publish 8099:8099 --publish 6022:22 \
    --name gitlab \
    --restart always \
    --volume /home/?/data/gitlab/:/etc/gitlab \
    --volume /home/?/data/gitlab/log:/var/log/gitlab \
    --volume /home/?/data/gitlab/data:/var/opt/gitlab \
 gitlab/gitlab-ce:11.8.1-ce.0
</code></pre>
</blockquote>
<ol>
<li>ssh 用6022 http 使用8099 非80端口 当然网站备案了也可以用80端口</li>
<li>hostname 使用你购买的域名 比如 gitlab.frp.?.cn</li>
<li>命令的？ 号是你要替换的域名,volume 需要你自定义你的映射本地地址</li>
<li>方向代理后的最终地址为 gitlab.frp.?.cn:8099</li>
</ol>
<blockquote>
<p>可以先看使用frp代理本地机器到公网教程后在 回来学习下面CI教程</p>
<p>root 进入gitlab 页面 <a href="http://gitlab.frp.?.com/admin/runners" target="_blank">http://gitlab.frp.?.com/admin/runners</a>
<img src="http://www.vonchange.com/doc/image/runner.jpg" alt="runner配置"></p>
</blockquote>
<h4 id="部署gitlab-runner"><a name="部署gitlab-runner" class="anchor-navigation-ex-anchor" href="#部署gitlab-runner"><i class="fa fa-link" aria-hidden="true"></i></a>部署gitlab-runner</h4>
<pre><code class="lang-angularjs">docker run -d --name gitlab-runner --restart always \
-v /home/?/data/gitlab-runner/config:/etc/gitlab-runner \
-v /run/docker.sock:/var/run/docker.sock \
gitlab/gitlab-runner:latest
</code></pre>
<blockquote>
<p> 注册</p>
</blockquote>
<pre><code class="lang-angularjs">docker exec -it gitlab-runner gitlab-ci-multi-runner register
</code></pre>
<blockquote>
<p>根据你的地址和token 注册 选择docker方式(企业级应当kubernetes shell等过时的不要用)</p>
<pre><code class="lang-angularjs">Please enter the gitlab-ci coordinator URL:
    http://?.com/
Please enter the gitlab-ci token for this runner:
    ?
Please enter the gitlab-ci description for this runner:
    commonh-runner
Please enter the gitlab-ci tags for this runner (comma separated):
    common
Whether to run untagged builds [true/false]:
    true
Please enter the executor: docker, parallels, shell, kubernetes, docker-ssh, ssh, virtualbox, docker+machine, docker-ssh+machine:
    docker 
Please enter the default Docker image (e.g. ruby:2.1):
    registry.cn-hangzhou.aliyuncs.com/xianbei_jdk/centos_jdk8:v1.2
</code></pre>
<p>配置可以不需要tag 运行
<img src="http://www.vonchange.com/doc/image/runner-config.jpg" alt="runner配置"></p>
<p>修改/home/?/data/gitlab-runner/config 下config.toml 配置maven npm缓存 地址可以改成本地的url</p>
</blockquote>
<pre><code class="lang-angularjs">[[runners]]
  name = &quot;common&quot;
  url = &quot;http://192.168.0.?:8099/&quot;
  token = &quot;?&quot;
  executor = &quot;docker&quot;
  [runners.custom_build_dir]
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]
  [runners.docker]
    tls_verify = false
    image = &quot;registry.cn-hangzhou.aliyuncs.com/xianbei_jdk/centos_jdk8:v1.2&quot;
    privileged = false
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes =  [&quot;/root/.npm:/root/.npm&quot;, &quot;/root/.ssh:/root/.ssh&quot;, &quot;/root/.sonar:/root/.sonar&quot;, &quot;/root/.m2:/root/.m2&quot;, &quot;/root/deploy:/root/deploy&quot;, &quot;/var/run/docker.sock:/var/run/docker.sock&quot;, &quot;/cache&quot;]
    pull_policy = &quot;if-not-present&quot;
    shm_size = 0
</code></pre>
<h4 id="部署helloworld"><a name="部署helloworld" class="anchor-navigation-ex-anchor" href="#部署helloworld"><i class="fa fa-link" aria-hidden="true"></i></a>部署helloworld</h4>
<p>项目下添加.gitlab-ci.yml 参考项目</p>
<blockquote>
<p><a href="https://github.com/VonChange/deploy-file" target="_blank">https://github.com/VonChange/deploy-file</a>
<a href="https://github.com/VonChange/hello-world" target="_blank">https://github.com/VonChange/hello-world</a></p>
</blockquote>
<p>master分支是 deploy-file项目把通用文件放到gitlab-runner挂载文件夹内 做到部署配置通用
all-in-code 是配置在同一项目内 可参考 不推荐使用</p>
<script type="text/javascript">var targetUl = document.getElementsByClassName('page-inner')[0].getElementsByTagName('ul')[0];if(targetUl.getElementsByTagName('a').length>0){targetUl.className='toc';}</script>

<pre><code class="lang-html">作者: 小白鼠V
链接: http://www.vonchange.com/doc/host/gitlab-ci.html
来源: 小白鼠V技术驿站
本文原创发布于「小白鼠V技术驿站」,转载请注明出处,谢谢合作!
</code></pre>
<p><footer class="page-footer"><span class="copyright">© vonchange all right reserved，powered by Gitbook</span><span class="footer-modification">文件修订时间: 
2020-07-05 07:52:17
</span></footer></p>
<div id="gitalk-container"></div>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="frp.html" class="navigation navigation-prev " aria-label="Previous page: 使用frp代理本地机器到公网">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="../idea.html" class="navigation navigation-next " aria-label="Next page: IDEA全系列最简单的破解方式">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"搭建gitlab并使用CICD部署HelloWorld","level":"1.3.3","depth":2,"next":{"title":"IDEA全系列最简单的破解方式","level":"1.4","depth":1,"path":"doc/idea.md","ref":"doc/idea.md","articles":[]},"previous":{"title":"使用frp代理本地机器到公网","level":"1.3.2","depth":2,"path":"doc/host/frp.md","ref":"doc/host/frp.md","articles":[]},"dir":"ltr"},"config":{"plugins":["toc","theme-comscore","pageview-count","-lunr","-search","search-plus","splitter","-sharing","sharing-plus","expandable-chapters-small","anchor-navigation-ex","edit-link-plus","code","chart","favicon-absolute","github-buttons","advanced-emoji","rss","sitemap-general","copyright","tbfed-pagefooter","mygitalk","donate","diff","simple-mind-map","hide-element","audio_image","icp","mermaid-gb3"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"&copy vonchange","modify_label":"文件修订时间: ","modify_format":"YYYY-MM-DD HH:mm:ss"},"diff":{"method":"diffChars","options":{},"type":"markdown"},"splitter":{},"copyright":{"copyProtect":false,"site":"http://www.vonchange.com/","author":"小白鼠V","website":"小白鼠V技术驿站"},"toc":{"addClass":true,"className":"toc"},"edit-link-plus":{"label":"编辑本页","base":{"vonchange.github.io":"https://github.com/VonChange/VonChange.github.io/edit/master"},"defaultBase":"https://github.com/VonChange/VonChange.github.io/edit/master"},"sharing-plus":{"qq":false,"all":["facebook","google","twitter","instapaper","linkedin","pocket","stumbleupon"],"douban":false,"facebook":true,"weibo":false,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":true,"messenger":false,"line":false,"vk":false,"pocket":true,"google":false,"viber":false,"stumbleupon":false,"qzone":false,"linkedin":false},"code":{"copyButtons":true},"donate":{"alipay":"/doc/image/zfb.jpeg","alipayText":"支付宝","button":"赏","title":"","wechat":"/doc/image/wx.jpeg","wechatText":"微信"},"favicon-absolute":{"appleTouchIconMore":{},"appleTouchIconPrecomposed152":"/apple-touch-icon-precomposed-152.png","appleTouchIconPrecomposedMore":{},"favicon":"/favicon.ico"},"sitemap-general":{"prefix":"http://www.vonchange.com/"},"hide-element":{"elements":["a.gitbook-link[href='https://www.gitbook.com']"]},"fontsettings":{"theme":"white","family":"sans","size":2},"rss":{"categories":["orm","k8s","devops","java"],"title":"小白鼠V技术驿站","description":"小白鼠V技术驿站","author":"vonchange","site_url":"http://www.vonchange.com/","feed_url":"http://www.vonchange.com/rss","managingEditor":"vonchange@163.com","webMaster":"vonchange@163.com"},"audio_image":{},"highlight":{},"mermaid-gb3":{},"anchor-navigation-ex":{"associatedWithSummary":true,"float":{"floatIcon":"fa fa-navicon","level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"mode":"float","multipleH1":true,"pageTop":{"level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"printLog":false,"showGoTop":true,"showLevel":true},"theme-comscore":{},"icp":{"link":"http://www.beian.miit.gov.cn/","style":{},"number":"鲁ICP备20022988号"},"pageview-count":{},"github-buttons":{"buttons":[{"user":"vonchange","repo":"vonchange.github.io","type":"star","size":"small"}]},"expandable-chapters-small":{},"mygitalk":{"flipMoveOptions":{},"clientID":"7f7363b6e6e3c9a06f4f","number":-1,"perPage":10,"proxy":"https://cors-anywhere.herokuapp.com/https://github.com/login/oauth/access_token","admin":["vonchange"],"createIssueManually":false,"distractionFreeMode":false,"repo":"vonchange.github.io","owner":"vonchange","enableHotKey":true,"clientSecret":"6e71673a0cfb622b535af4c00b0622cf2d34d31b","pagerDirection":"last","labels":["Gitalk"]},"advanced-emoji":{"embedEmojis":false},"sharing":{"qq":true,"all":["facebook","google","twitter","weibo","instapaper","linkedin","pocket","stumbleupon"],"douban":true,"facebook":false,"weibo":true,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":false,"messenger":false,"line":false,"vk":false,"pocket":false,"google":false,"viber":false,"stumbleupon":false,"qzone":true,"linkedin":false},"simple-mind-map":{"autoFit":true,"linkShape":"diagonal","preset":"colorful","style":{},"type":"markdown"},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"chart":{"type":"c3"},"search-plus":{}},"theme":"default","author":"vonchange","baidu-site-verification":"cAxqlT3C5k","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"小白鼠V技术驿站","language":"zh-hans","links":{"sidebar":{"小白鼠V的技术博客":"http://www.vonchange.com/"}},"gitbook":"3.2.3","description":"小白鼠V技术驿站"},"file":{"path":"doc/host/gitlab-ci.md","mtime":"2020-07-04T23:52:17.913Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2021-01-10T13:01:43.103Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-pageview-count/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search-plus/jquery.mark.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search-plus/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing-plus/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-edit-link-plus/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-code/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-github-buttons/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-rss/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-copyright/plugin.js"></script>
        
    
        
        <script src="https://cdn.bootcss.com/blueimp-md5/2.12.0/js/md5.min.js"></script>
        
    
        
        <script src="/myfile/gitalk/dist/gitalk.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-mygitalk/mygitalk.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-donate/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-simple-mind-map/bundle.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-hide-element/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-mermaid-gb3/book/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    <script src="../../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.min.js"></script>

    </body>
</html>

